<?php
/**
 * @package Autogenerator for Joomla!
 * @version 3.0.0
 * @author Truong Cong Duc <truongcongduc4@gmail.com>
 * @link autogenerator.blogspot.com
 * @copyright (c) 2013, Truong Cong Duc
 * @license GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('JPATH_BASE') or die;

abstract class AutogeneratorHtmlTable
{

    protected static $aItems = array();

    public static function options()
    {
        $sHash = md5('autogenerator.table');

        if (!isset(self::$aItems[$sHash]))
        {
            $oDatabase = JFactory::getDbo();
            $oQuery = $oDatabase->getQuery(true);

            $oQuery->select('component.id, component.title')
                    ->from('#__auto_component AS component')
                    ->where('component.status = 1')
                    ->order('component.ordering');

            $oDatabase->setQuery($oQuery);
            $aItems = $oDatabase->loadObjectList();

            // Assemble the list options.
            self::$aItems[$sHash] = array();

            foreach ($aItems as &$oItem)
            {
                self::$aItems[$sHash][] = JHtml::_('select.option', $oItem->id, $oItem->title);
            }
        }

        return self::$aItems[$sHash];
    }

}
